package org.zjx.analysis.analyze.window.impl;

import com.sun.jna.platform.win32.COM.IUnknown;
import lombok.Getter;
import org.zjx.analysis.analyze.window.AbstractWindowAnalyzer;
import org.zjx.analysis.identify.IdentifyFontUtil;
import org.zjx.command.entity.ParagraphBean;
import org.zjx.command.enums.FontType;
import org.zjx.command.util.ImageUtil;
import org.zjx.window.window.IWindow;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Collections;
import java.util.List;

public class DialogueAnalyzer extends AbstractWindowAnalyzer {
    @Getter
    private List<ParagraphBean.Word> wordList;

    public DialogueAnalyzer(IWindow window) {
        super("对话", "NPC 交互", window);
    }

    @Override
    protected void initResources() {

    }

    @Override
    public void analyze(BufferedImage image) {
        Rectangle rectangle = conversion(windowArea,getContentArea());
        BufferedImage bufferedImage = ImageUtil.cutImage(image, rectangle);
        wordList = IdentifyFontUtil.identify(bufferedImage,Collections.singletonList(new Color(238, 0, 0)), IdentifyFontUtil.getFontAttributes(FontType.NPC), 14, false);
    }



    public Rectangle getContentArea() {
        return ImageUtil.createRect(11,36,501,183);
    }

    @Override
    public Rectangle closeArea() {
        return ImageUtil.createRect(524, 33, 539, 48);
    }

    @Override
    public Rectangle getOriginBounds() {
        return ImageUtil.createRect(134, 261, 675, 463);
    }

    @Override
    public Rectangle getRefImageArea() {
        return ImageUtil.createRect(506, 170, 521, 184);
    }

    @Override
    public BufferedImage getRefImage() {
        return ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAAPCAYAAADtc08vAAAA40lEQVR4Xm1SqxXDMAz0/hMUBgZ2iICCgoACw8BukUbSnXxyA/T8LOk+kt36ez37tpwHzv5a6rk94rS65SQM0/xiRRIYAOBjB2gCa94JUh3KfieA6lNYTzgA0FlZ+DyhGkRsTkJxEyN4DFVaTKtlJ7xHLUbYh4Krl5yMo4H+GIH2EqChwPVmBBC4IvagAHWXISTYAdTUSTqrhOpk/AMW+GnUpqjf7aRVywGO7Ud+fj67f69FM99KY7EeznIv6Qo54MY/mOc3UjaWsWSpsYPBNs9XXoAEWB5HlZ9Yg8/694RWk9wP00IQsvCQR7oAAAAASUVORK5CYII=");
    }
}
